Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for duplicate type field in ELM JSON #1403

Merged
merged 6 commits into from
Aug 16, 2024
Merged

Conversation

antvaset
Copy link
Contributor

@antvaset antvaset commented Aug 16, 2024

The ChoiceTypeSpecifier ELM node has a deprecated type element which, if not null, clashes with the "type" : "ChoiceTypeSpecifier" field in the JSON serialisation of the node. This does not happen in the XML serialisation which nests <type> tags inside <ChoiceTypeSpecifier>.
Because the type element is deprecated, it is not normally populated by the compiler anymore and stays null in the ChoiceTypeSpecifier instance. It is however set to an empty list if you just call ChoiceTypeSpecifier.getType() (which we do during the ELM optimisation stage in the compiler).

This PR adds a new REMOVE_CHOICE_TYPE_SPECIFIER_TYPE_IF_EMPTY edit to phase 5 of compilation. The edit "protects" the downstream JSON serialisation if it can be done without data loss.

I also changed the ensureNoDirectElmConstruction ArchUnit test to allow direct ELM construction in Java tests. This allowed me to instantiate ELM nodes (only in the tests) in a quick way without using the object factory.

Closes #1380.

Copy link

Formatting check succeeded!

@antvaset antvaset changed the title Remove choice type specifier type if empty. Fix for duplicate type field in ELM JSON Aug 16, 2024
Copy link

codecov bot commented Aug 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.73%. Comparing base (bc10dbe) to head (cbb4ff9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1403      +/-   ##
============================================
+ Coverage     63.72%   63.73%   +0.01%     
  Complexity     2665     2665              
============================================
  Files           493      493              
  Lines         27774    27782       +8     
  Branches       5521     5523       +2     
============================================
+ Hits          17700    17708       +8     
  Misses         7831     7831              
  Partials       2243     2243              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@antvaset antvaset marked this pull request as ready for review August 16, 2024 05:21
@JPercival JPercival merged commit 16daba2 into master Aug 16, 2024
5 checks passed
@JPercival JPercival deleted the duplicate-type-in-elm-json branch August 16, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate Type attribute when using ElmLibraryWriter to generate JSON from Library
3 participants